<template lang="jade">
h-loader-full(url='loader',:setdata='false')
  h-data-lister(data='list')

  m-title(icon="add",name="长城体检表")
    label 开始时间
    input(type='datetime-local', v-model="start_time")
    label 结束时间
    input(type='datetime-local', v-model="end_time")
    button(@click='filter_time') 过滤
  .box
    //人员信息
    table.list
      ml-header(data='意向地区,姓名,性别,政治面貌,婚姻状况,民族,籍贯,户口所在地,家庭电话,手机号码,身份证号,学历,毕业时间,毕业学校,专业,备注,创建时间,操作')
      tr

        td 
          input(type = 'text',v-model='search.address_w', style="width:50px") 

        td 
          input(type = 'text',v-model='search.name', style="width:50px") 

        td 
          input(type = 'text',v-model='search.sex', style="width:50px") 

        td 
          input(type = 'text',v-model='search.zzmm', style="width:50px") 

        td 
          input(type = 'text',v-model='search.hyzk', style="width:50px") 

        td 
          input(type = 'text',v-model='search.minzu', style="width:50px") 

        td 
          input(type = 'text',v-model='search.jiguan', style="width:50px") 

        td 
          input(type = 'text',v-model='search.address_h', style="width:50px") 

        td 
          input(type = 'text',v-model='search.tel', style="width:50px") 

        td 
          input(type = 'text',v-model='search.phone', style="width:50px") 

        td 
          input(type = 'text',v-model='search.number', style="width:50px") 

        td 
          input(type = 'text',v-model='search.education', style="width:50px") 

        td 
          input(type = 'text',v-model='search.overtime', style="width:50px") 

        td 
          input(type = 'text',v-model='search.school', style="width:50px") 

        td 
          input(type = 'text',v-model='search.major', style="width:50px") 

        td 
          input(type = 'text',v-model='search.beizhu', style="width:50px") 
          
        td
        td
          button(@click='searchdo(search)') 搜索


      tr(v-for='(n,i) in list')
        td {{n.address_w}}
        td {{n.name}}
        td {{n.sex}}
        td {{n.zzmm}}
        td {{n.hyzk}}
        td {{n.minzu}}
        td {{n.jiguan}}
        td {{n.address_h}}
        td {{n.tel}}
        td {{n.phone}}
        td {{n.number}}
        td {{n.education}}
        td {{n.overtime}}
        td {{n.school}}
        td {{n.major}}
        td {{n.beizhu}}

        td {{new Date(n.time_create * 1000).format('yyyy-MM-dd hh:mm:ss') }}

        td(style="width:80px")
          a(:href="'./changchengedit.html?id=' + n.id") 编辑
          a(@click='deleteinfo(n.id)' href='') 删除

    .command
      .page
        button(v-show='page>1', @click="pagego('last')") 上一页
        button {{page}}
        button(@click="pagego('next')") 下一页
        a.button(href='javascript:void(0)',@click='download()') 导出
        &nbsp;&nbsp;&nbsp;&nbsp;统计共有{{count_num}}条记录

</template>
<style>
  #title .filter{ padding-top: 0; }
</style>
<script>
import { MessageBox } from 'mint-ui'
export default {
	data () {
		return {
			loader:{
        list:'get/changcheng/info?page=1' 
        },
      list:[],
      page:1,
      count_num:0,
      start_time:"",
      end_time:"",

      search:{
        address_w:"",
        name:"",
        sex:"",
        zzmm:"",
        hyzk:"",
        minzu:"",
        jiguan:"",
        address_h:"",
        tel:"",
        phone:"",
        number:"",
        education:"",
        overtime:"",
        school:"",
        major:"",
        beizhu:"",
      },



		} 
	},
  mounted () {
    //this.getcount()
  },
  watch:{
    list:function(){
      this.getcount();
      for(var key in this.list){
        if(this.list[key].object != null){
          this.list[key].object = eval('(' + this.list[key].object + ')');
        }else{
          this.list[key].object = {'sex':'', 'age':'', 'intention':'', 'area':''};
        }
        console.log(this.list[key].object);
      }
    }
  },
	methods: {
		loadAfter(data){
      this.list=data.list
		},
    download(){
      	window.location.href = 'http://xiongan.manager.hesq.com.cn/rest/get/excel/changcheng/info'
    },
    // 分页
    pagego (type) {
      var start_time = this.start_time;
      var end_time = this.end_time;
      var search = this.search;

      this.page = type == 'last' ? this.page - 1 : this.page + 1
      this.$ajax.get('get/changcheng/info?&page=' + this.page + '&start_time='+start_time+"&end_time="+end_time+

        '&address_w=' + search.address_w +
        '&name=' + search.name +
        '&sex=' + search.sex +
        '&zzmm=' + search.zzmm +
        '&hyzk=' + search.hyzk +
        '&minzu=' + search.minzu +
        '&jiguan=' + search.jiguan +
        '&address_h=' + search.address_h +
        '&tel=' + search.tel +
        '&phone=' + search.phone +
        '&number=' + search.number +
        '&education=' + search.education +
        '&overtime=' + search.overtime +
        '&school=' + search.school +
        '&major=' + search.major +
        '&beizhu=' + search.beizhu,


        (res) => {
        this.list = res.data
      }, (res) => {
        this.error(res.message)
      })
    },
    getcount(){
      var start_time = this.start_time;
      var end_time = this.end_time;
      this.$ajax.get('get/jobseeker/count?type=changcheng&start_time='+start_time+'&end_time='+end_time, (res) => {
        var count_num = 0;
        this.count_num = res.data[0].countnum
      }, (res) => {
        this.error(res.message)
      })
    },
    filter_time(){
      var start_time = this.start_time;
      var end_time = this.end_time;
      var search = this.search;
      this.$ajax.get(
        'get/changcheng/info?&page=1&start_time='+start_time+"&end_time="+end_time+

        '&address_w=' + search.address_w +
        '&name=' + search.name +
        '&sex=' + search.sex +
        '&zzmm=' + search.zzmm +
        '&hyzk=' + search.hyzk +
        '&minzu=' + search.minzu +
        '&jiguan=' + search.jiguan +
        '&address_h=' + search.address_h +
        '&tel=' + search.tel +
        '&phone=' + search.phone +
        '&number=' + search.number +
        '&education=' + search.education +
        '&overtime=' + search.overtime +
        '&school=' + search.school +
        '&major=' + search.major +
        '&beizhu=' + search.beizhu,

        (res) => {
        this.list = res.data
      }, (res) => {
        this.error(res.message)
      })
      this.getcount();
    },

    searchdo(search){
      var start_time = this.start_time;
      var end_time = this.end_time;

      this.$ajax.get(
        'get/changcheng/info?&page=' + this.page + 

        '&address_w=' + search.address_w +
        '&name=' + search.name +
        '&sex=' + search.sex +
        '&zzmm=' + search.zzmm +
        '&hyzk=' + search.hyzk +
        '&minzu=' + search.minzu +
        '&jiguan=' + search.jiguan +
        '&address_h=' + search.address_h +
        '&tel=' + search.tel +
        '&phone=' + search.phone +
        '&number=' + search.number +
        '&education=' + search.education +
        '&overtime=' + search.overtime +
        '&school=' + search.school +
        '&major=' + search.major +
        '&beizhu=' + search.beizhu,

        (res) => {
        console.log(res)
        this.list = res.data
      }, (res) => {
        this.error(res.message)
      })
    },

    deleteinfo(id){
      if(confirm('确定要删除？')){
        this.$ajax.get('get/delete/changcheng/'+id);
      }
    }


	}
}
</script>
<style>
  .button{background: #ff5700; padding: 2%; color: #fff; text-decoration-line: none;}
</style>
